{{ if or .Site.Params.gcs_engine_id .Site.Params.algolia_docsearch }}
<div class="add-search-icon">
<input type="search" class="form-control td-search-input" placeholder="{{ T "ui_search" }}" aria-label="{{ T "ui_search" }}" autocomplete="off">
<svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="0.88 0.63 32.17 30.24"><g opacity=".945"><path stroke="#000" stroke-width="4.392" d="M13.746 23.279c5.536 0 10.024-4.432 10.024-9.9 0-5.466-4.488-9.898-10.024-9.898-5.536 0-10.024 4.432-10.024 9.899 0 5.467 4.488 9.899 10.024 9.899zm6.56-5.069l10.652 10.52" fill="transparent" /></g></svg>
</div>
{{ else if .Site.Params.offlineSearch }}
{{ $offlineSearchIndex := resources.Get "json/offline-search-index.json" | resources.ExecuteAsTemplate "offline-search-index.json" . }}
{{ $offlineSearchLink := $offlineSearchIndex.RelPermalink -}}
{{ if hugo.IsProduction -}}
{{/* Use `md5` as finger print hash function to shorten file name to avoid `file name too long` error. */}}
{{ $offlineSearchIndexFingerprint := $offlineSearchIndex | resources.Fingerprint "md5" }}
{{ $offlineSearchLink = $offlineSearchIndexFingerprint.RelPermalink -}}
{{ end -}}

<div class="add-search-icon">
<input
  type="search"
  class="form-control td-search-input"
  placeholder="{{ T "ui_search" }}"
  aria-label="{{ T "ui_search" }}"
  autocomplete="off"
  {{/*
    The data attribute name of the json file URL must end with `src` since
    Hugo's absurlreplacer requires `src`, `href`, `action` or `srcset` suffix for the attribute name.
    If the absurlreplacer is not applied, the URL will start with `/`.
    It causes the json file loading error when when relativeURLs is enabled.
    https://github.com/google/docsy/issues/181
  */}}
  data-offline-search-index-json-src="{{ $offlineSearchLink }}"
  data-offline-search-base-href="/"
  data-offline-search-max-results="{{ .Site.Params.offlineSearchMaxResults | default 10 }}"
>
<svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="0.88 0.63 32.17 30.24"><g opacity=".945"><path stroke="#000" stroke-width="4.392" d="M13.746 23.279c5.536 0 10.024-4.432 10.024-9.9 0-5.466-4.488-9.898-10.024-9.898-5.536 0-10.024 4.432-10.024 9.899 0 5.467 4.488 9.899 10.024 9.899zm6.56-5.069l10.652 10.52" fill="transparent" /></g></svg>
</div>
{{ end }}
